Ext.define('PJ.view.trainingprogram.List', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.trainingProgramList'],
    requires: ['AM.default.DefaultSearchForm',
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.DefaultDoubleDateField',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
		       'AM.default.DefaultActiveStateCombo',
		       'PJ.view.quotamanagement.PlanPlacesList',//计划名额
		       'AM.default.DateMonth',
		       'PJ.view.trainingprogram.UnitsIssuedList',//已下发单位
		       'PJ.view.trainingprogram.FeedbackList'//查看反馈意见
               ],
    initComponent: function(){
    	var me= this;
    	this.columns = [{
    		header: '计划编号',
    		dataIndex: 'applyNum',
    		width: 120,
    		renderer: function(value, meta, record){
    			return value;
    		}
    	},{
            header: '培训班名称',
            dataIndex: 'className',
            flex: 1,
            minWidth: 120,
    		renderer: function(value, metaData, record){
    			metaData.style = "white-space:normal;cursor: pointer;color:blue;";
    			metaData.tdAttr = "data-qtip='" + value + "' planId=" + record.get("planId") + " versionState=" + record.get("versionState");
    			return value;
    		},
    		listeners: {
    			click: function(g, clm){
    				var planId = clm.getAttribute("planId");
    				var versionState = clm.getAttribute("versionState");
    				if(versionState == "2"){
    					win = Ext.create('PJ.view.codtrainingprogram.NoneVersionView', {
        					title: "查看培训计划",
        					flag:4,
        					grid: me,
        					isDisable:false,
        					planId:planId,
        		        	isReadOnly:true
        				}).show();
        				var actionName = "load";
        				if(gj_onlineLearning_constant.loadType == "jsonp"){
        					actionName = "loadJsonp";
        				}
        				win.down("form").getForm().doAction(actionName,{
        					url:me.store.preUpdateUrl,
        					params:{
        						planId: planId
        					},
        					success:function(f,action){
        						var data = action.response.responseText;
        	        			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
        	        			var form = win.down('form');	 
        	        			var baseForm = form.getForm();
        					}
        				});
    				}else if(versionState == "1"){
    					win = Ext.create('PJ.view.trainingprogram.View', {
        		        	title: "查看培训计划",
        		            flag:2,
        		        	grid: me,
        		        	isDisable:true,
        		        	planId:planId,
        		        	isReadOnly:true
        		        }).show();
        				var actionName = "load";
        				if(gj_onlineLearning_constant.loadType == "jsonp"){
        					actionName = "loadJsonp";
        				}
        				win.down("form").getForm().doAction(actionName,{
        		    		url:me.store.preUpdateUrl,
        		    		params:{
        		    			planId: planId
        		    		},
        		    		success:function(f,action){
        		    			var data = action.response.responseText;
        		    			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
        		    			var form = win.down('form');	 
        		    			var baseForm = form.getForm();
        		    			if(!json.data.classNameState){
//        		    				baseForm.findField("classNameOld").setFieldLabel("<span style='color:red;'>专题名称:</span>");
        		    				baseForm.findField("classNameNew").setFieldLabel("<span style='color:red;'>培训班名称:</span>");
        		    			}
        		    			if(!json.data.applyNumState){
//        		    				baseForm.findField("applyNumOld").setFieldLabel("<span style='color:red;'>计划申请编号:</span>");
        		    				baseForm.findField("applyNumNew").setFieldLabel("<span style='color:red;'>计划申请编号:</span>");
        		    			}
        		    			if(!json.data.undertakeNameState){
//        		    				baseForm.findField("undertakeNameOld").setFieldLabel("<span style='color:red;'>承办部委:</span>");
        		    				baseForm.findField("undertakeNameNew").setFieldLabel("<span style='color:red;'>承办部委:</span>");
        		    			}
        		    			if(!json.data.jointNameState){
//        		    				baseForm.findField("jointNameOld").setFieldLabel("<span style='color:red;'>合办部委:</span>");
        		    				baseForm.findField("jointNameNew").setFieldLabel("<span style='color:red;'>合办部委:</span>");
        		    			}
//        		    			if(!json.data.planDateState){
////        		    				baseForm.findField("planDateOld").setFieldLabel("<span style='color:red;'>计划时间:</span>");
//        		    				baseForm.findField("planDateNew").setFieldLabel("<span style='color:red;'>计划时间:</span>");
//        		    			}
        		    			if(!json.data.startPlanDateStateStr){
//        		    				baseForm.findField("planDateOld").setFieldLabel("<span style='color:red;'>计划时间:</span>");
        		    				baseForm.findField("startPlanDateNewStr").setFieldLabel("<span style='color:red;'>计划开始时间:</span>");
        		    			}
        		    			if(!json.data.endPlanDateStateStr){
//        		    				baseForm.findField("planDateOld").setFieldLabel("<span style='color:red;'>计划时间:</span>");
        		    				baseForm.findField("endPlanDateNewStr").setFieldLabel("<span style='color:red;'>计划结束时间:</span>");
        		    			}
        		    			if(!json.data.planDayState){
//        		    				baseForm.findField("planDayOld").setFieldLabel("<span style='color:red;'>学制（天）:</span>");
        		    				baseForm.findField("planDayNew").setFieldLabel("<span style='color:red;'>学制（天）:</span>");
        		    			}
        		    			if(!json.data.classObjectiveState){
//        		    				baseForm.findField("classObjectiveOld").setFieldLabel("<span style='color:red;'>办班目的:</span>");
        		    				baseForm.findField("classObjectiveNew").setFieldLabel("<span style='color:red;'>办班目的:</span>");
        		    			}
        		    			if(!json.data.classValuesState){
//        		    				baseForm.findField("classValuesOld").setFieldLabel("<span style='color:red;'>培训内容:</span>");
        		    				baseForm.findField("classValuesNew").setFieldLabel("<span style='color:red;'>培训内容:</span>");
        		    			}
        		    			if(!json.data.trainingObjectState){
//        		    				baseForm.findField("trainingObjectOld").setFieldLabel("<span style='color:red;'>调训对象:</span>");
        		    				baseForm.findField("trainingObjectNew").setFieldLabel("<span style='color:red;'>调训对象:</span>");
        		    			}
        		    			if(!json.data.trainingAddressState){
//        		    				baseForm.findField("trainingAddressOld").setFieldLabel("<span style='color:red;'>培训地点:</span>");
        		    				baseForm.findField("trainingAddressNew").setFieldLabel("<span style='color:red;'>培训地点:</span>");
        		    			}
        		    			if(!json.data.linkManState){
//        		    				baseForm.findField("linkManOld").setFieldLabel("<span style='color:red;'>联系人:</span>");
        		    				baseForm.findField("linkManNew").setFieldLabel("<span style='color:red;'>联系人:</span>");
        		    			}
        		    			if(!json.data.linkModeState){
//        		    				baseForm.findField("linkModeOld").setFieldLabel("<span style='color:red;'>联系电话:</span>");
        		    				baseForm.findField("linkModeNew").setFieldLabel("<span style='color:red;'>联系电话:</span>");
        		    			}
        		    			if(!json.data.faxState){
//        		    				baseForm.findField("faxOld").setFieldLabel("<span style='color:red;'>联系电话:</span>");
        		    				baseForm.findField("faxNew").setFieldLabel("<span style='color:red;'>传真:</span>");
        		    			}
        		    		}
        		    	});
    				}
    			}
    		}
        },{
            header: '计划调训人数',
            dataIndex: 'planNum',
            width: 90 
        },{
            header: '学制（天）',
            dataIndex: 'planDay',
            width: 80 
        }/*,{
            header: '计划时间',
            dataIndex: 'planDate',
            width: 80 
        }*/,{
            header: '计划开始时间',
            dataIndex: 'startPlanDateStr',
            width: 80 
        },{
            header: '计划结束时间',
            dataIndex: 'endPlanDateStr',
            width: 80 
        },{
            header: '审核状态',
            dataIndex: 'auditState',
            width: 70,
            renderer: function(v, metaData, record){
               metaData.tdAttr = "planId=" + record.get("planId") + " auditState=" + v + " rejectReason=" + record.get("rejectReason");
               if(v == 1){
            	   return "审核通过";
               }else if(v == 2){
            	   metaData.style = "cursor: pointer;color:blue;";
            	   return "建议修改";
               }else if(v == 3){
            	   return "待审核";
               }else if(v == 4){
            	   return "未上报";
               }else if(v == 5){
            	   metaData.style = "color:red;";
            	   return "审核否决";
               }
            },
    		listeners: {
    			click: function(g, clm){
    				var approvalStatus = clm.getAttribute("auditState");
    				var planId = clm.getAttribute("planId");
    				var rejectReason = clm.getAttribute("rejectReason");
    				if(approvalStatus!=2){
    					return;
    				}else{
    					win = Ext.create('PJ.view.codtrainingprogram.AuditOpinionEdit', {
        					title: "查看建议修改意见",
        					isView:true
        				}).show();
    					var form = win.down('form');	 
	        			var baseForm = form.getForm();
	        			rejectReason = decodeURI(rejectReason);
        				baseForm.findField("rejectReason").setValue(rejectReason);
    				}
    			}
    		}
        },{
            header: '下发状态（反馈数/下发数）',
            dataIndex: 'issuedState',
            width: 155,
            renderer: function(v, metaData, record){
            	metaData.tdAttr = "planId=" + record.get("planId") + " issuedState=" + v;
               if(v == 1){
            	   metaData.style = "cursor: pointer;color:blue;";
            	   return record.get("issuedStr");
               }else if(v == 2){
            	   return "未下发";
               }else if(v == 3){
            	   metaData.style = "cursor: pointer;color:blue;";
            	   return record.get("issuedStr");
               }
            },
    		listeners: {
    			click: function(g, clm){
    				var issuedState = clm.getAttribute("issuedState");
    				var planId = clm.getAttribute("planId");
    				if(issuedState == 1){
    					Ext.create('AM.default.DefaultWindowView', {
    			            title: "查看已下发单位",
    			            height:350,
    			            width: 350,
    			            grid: me,
    			            planId:planId,
    			            items: [{
    			                xtype: 'unitsIssuedList',
    			                planId:planId,
    			                isView: true
    			            }],
    			            listeners: {
    			            	close: function(){
    			            		me.getStore().load();
    			            	}
    			            }
    			        });
    				}else if(issuedState == 3){
    					Ext.create('AM.default.DefaultWindowView', {
    			            title: "查看反馈意见",
    			            height:450,
    			            width: 550,
    			            grid: me,
    			            planId:planId,
    			            items: [{
    			                xtype: 'feedbackList',
    			                planId:planId,
    			                isView: true
    			            }],
    			            listeners: {
    			            	close: function(){
    			            		me.getStore().load();
    			            	}
    			            }
    			        });
    				}else {
    					return;
    				}
    			}
    		}
        },{
            header: '发布状态',
            dataIndex: 'publishState',
            width: 70,
            renderer: function(v, metaData, record){
               if(v == 1){
            	   return '<span style="color:green;">已发布</span>';
               }else if(v == 2){
            	   return '<span style="color:red;">未发布</span>';
               }
            }
        }];
    	
        this.store = Ext.create('PJ.'+ prototype +'.trainingprogram.List',{
        	isLoad: true
        });
        this.callParent(arguments);
        this.loadType = gj_onlineLearning_constant.loadType;//加载方式
    },
	//新增
	onAddClick:function(){
        var me = this;
        var selectScopeStr = $(document.getElementById("selectScope")).find("option:selected").text();
        Ext.create('PJ.view.trainingprogram.Add',{
        	title: "新增培训班",
            flag:1,
        	grid: me,
        	isDisable:true,
        	isReadOnly:false,
        	isAdd: true,
        	selectScopeStr: selectScopeStr
        });
    },
	//修改
	onUpdateClick:function(){
		var me = this;
		var selectScopeStr = $(document.getElementById("selectScope")).find("option:selected").text();
		var record=me.getSelectionModel().getSelection();
    	var planId = record[0].get("planId");
    	if(record[0].get("auditState") == 5){
    		Ext.Msg.show({
                title: '提示',
                msg: '审核否决的信息不允许再进行任何操作!',
                icon: Ext.Msg.WARNING,
                buttons: Ext.Msg.OK
            });
        	return;
    	}
		if(this.getSelectionModel().getCount() > 1){
            Ext.Msg.show({
                title: '提示',
                msg: '操作时只可选中一条记录！',
                icon: Ext.Msg.WARNING,
                buttons: Ext.Msg.OK
            });
        	return;
        }
		if(record[0].get("auditState")==1 || record[0].get("auditState")==3){
			Ext.Msg.show({
                title: '提示',
                msg: '只允许对未审核或建议修改的数据执行修改操作!',
                icon: Ext.Msg.WARNING,
                buttons: Ext.Msg.OK
            });
        	return;
		}
        win = Ext.create('PJ.view.trainingprogram.Edit', {
        	title: "更新培训班",
            flag:2,
        	grid: me,
        	isDisable:true,
        	planId:planId,
        	isReadOnly:false,
        	isAdd: false,
        	selectScopeStr: selectScopeStr
        }).show();
		var actionName = "load";
		if(gj_onlineLearning_constant.loadType == "jsonp"){
			actionName = "loadJsonp";
		}
		win.down("form").getForm().doAction(actionName,{
    		url:me.store.preUpdateUrl,
    		params:{
    			planId: planId
    		},
    		success:function(f,action){
    			var data = action.response.responseText;
    			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
    			var form = win.down('form');	 
    			var baseForm = form.getForm();
    			baseForm.findField("planId").setValue(json.data.planIdNew);
    			//baseForm.findField("classNum").setValue(json.data.classNum);
    			//baseForm.findField("classNum_").setValue(json.data.classNum);
    		}
    	});
	},
	//删除
	onDeleteClick:function(){
  	  var me = this;
  	  var store = me.getStore();
  	  var records = me.getSelectionModel().getSelection();
  	  for(var i=0;i<records.length;i++){
  		  if(records[i].get("auditState")!=4&&records[i].get("auditState")!=5){
  			Ext.Msg.show({
  				  title: '提示',
  			  	  msg  : '只允许删除未审核的数据！',
  			  	  icon :Ext.Msg.WARNING,
  			  	  buttons:Ext.Msg.OK
  			  });
  			  return;
  		  }
  		  if(records[i].get("auditState") == 5){
			Ext.Msg.show({
	            title: '提示',
	            msg: '审核否决的信息不允许再进行任何操作!',
	            icon: Ext.Msg.WARNING,
	            buttons: Ext.Msg.OK
	        });
	    	return;
  		  }
  	  };
  	Ext.Msg.confirm({
		  title:'提示',
		  msg:'您确定要删除这些数据吗?',
		  icon:Ext.Msg.WARNING,
		  buttons:Ext.Msg.OKCANCEL,
		  fn:function(id){
			  if(id=='ok'){
				  var planIds= new Array();
				  var applyNums = new Array();
				  Ext.Array.each(records,function(name,index){
					  planIds.push(name.get('planId'));
					  applyNums.push(name.get('applyNum'));
				  });
				  if(gj_onlineLearning_constant.loadType == "jsonp"){
					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                  		loadType: gj_onlineLearning_constant.loadType,
                          url: store.deleteUrl,
                  		  extraParams: {
                  			searchPlanIds: planIds,
							  submintType: 'activeStateToN',
							  applyNums: applyNums
                          }
                  	});
                  	store1.load(function(rec, operation, success){
                  		if(success){
                              Ext.Msg.alert('消息', '删除成功！', function(){
                                  var store = me.getStore();
                                  store.load();
                              });
                          }else{
                              Ext.Msg.alert('消息', operation.error);
                          }
                  	});
				  }else{
					  Ext.Ajax.request({
						  url:store.deleteUrl,
						  params: {
							  searchPlanIds: planIds,
							  submintType: 'activeStateToN',
							  applyNums: applyNums
	                       },
						  success:function(response){
							  var data=response.responseText;
							  var json=Ext.decode(data,true);
							  if(json.success){
								  Orchid.alert('提示','删除成功!',function(){
									  store.load();
								  });
							  }else{
								  Orchid.alert('提示',json.msg);
							  }
						  }
					  });
				  }
			  }
		  }
	  });
	},
	//提交审核
	onIssueClick:function(){
  	  var me=this;
  	  var store=me.getStore();
  	  var records=me.getSelectionModel().getSelection();
  	  for(var i=0;i<records.length;i++){
  		  if(records[i].get("auditState")!=4&&records[i].get("auditState")!=2&&records[i].get("auditState")!=5){
  			Ext.Msg.show({
  				  title: '提示',
  			  	  msg  : '只允许对未审核或建议修改的数据执行提交审核操作!',
  			  	  icon :Ext.Msg.WARNING,
  			  	  buttons:Ext.Msg.OK
  			  });
  			  return;
  		  }
  		  if(records[i].get("auditState") == 5){
			Ext.Msg.show({
		          title: '提示',
		          msg: '审核否决的信息不允许再进行任何操作!',
		          icon: Ext.Msg.WARNING,
		          buttons: Ext.Msg.OK
		        });
			  return;
  		  }
  	  };
  	Ext.Msg.confirm({
		  title:'提示',
		  msg:'您确定要提交审核吗?',
		  icon:Ext.Msg.WARNING,
		  buttons:Ext.Msg.OKCANCEL,
		  fn:function(id){
			  if(id=='ok'){
				  var planIds= new Array();
				  Ext.Array.each(records,function(name,index){
					  planIds.push(name.get('planId'));
				  });
				  if(gj_onlineLearning_constant.loadType == "jsonp"){
					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                  		loadType: gj_onlineLearning_constant.loadType,
                          url: store.issueUrl,
                  		  extraParams: {
                  			searchPlanIds: planIds
                          }
                  	});
                  	store1.load(function(rec, operation, success){
                  		if(success){
                              Ext.Msg.alert('消息', '提交审核成功！', function(){
                                  var store = me.getStore();
                                  store.load();
                              });
                          }else{
                              Ext.Msg.alert('消息', operation.error);
                          }
                  	});
				  }else{
					  Ext.Ajax.request({
						  url:store.issueUrl,
						  params: {
	                  			searchPlanIds: planIds
						  },
						  success:function(response){
							  var data=response.responseText;
							  var json=Ext.decode(data,true);
							  if(json.success){
								  Orchid.alert('提示','提交审核成功!',function(){
									  store.load();
								  });
							  }else{
								  Orchid.alert('提示',json.msg);
							  }
						  }
					  });
				  }
			  }
		  }
	  });
	},
	//撤回审核
	onIssuenoClick:function(){
		var me=this;
		var store=me.getStore();
		var records=me.getSelectionModel().getSelection();
		for(var i=0;i<records.length;i++){
			if(records[i].get("auditState") !=3&&records[i].get("auditState") !=2&&records[i].get("auditState")!=5){
				Ext.Msg.show({
					title: '提示',
					msg  : '只允许对待审核的数据执行撤回审核操作!',
					icon :Ext.Msg.WARNING,
					buttons:Ext.Msg.OK
				});
				return;
			}
			if(records[i].get("auditState") == 5){
	    		Ext.Msg.show({
	                title: '提示',
	                msg: '审核否决的信息不允许再进行任何操作!',
	                icon: Ext.Msg.WARNING,
	                buttons: Ext.Msg.OK
	            });
	        	return;
	    	}
		};
		Ext.Msg.confirm({
			title:'提示',
			msg:'您确定要对这些数据执行撤回审核操作吗?',
			icon:Ext.Msg.WARNING,
			buttons:Ext.Msg.OKCANCEL,
			fn:function(id){
				if(id=='ok'){
					var planIds= new Array();
					Ext.Array.each(records,function(name,index){
						planIds.push(name.get('planId'));
					});
					if(gj_onlineLearning_constant.loadType == "jsonp"){
						var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
							loadType: gj_onlineLearning_constant.loadType,
							url: store.noIssueUrl,
							extraParams: {
	                  			searchPlanIds: planIds
							}
						});
						store1.load(function(rec, operation, success){
							if(success){
								Ext.Msg.alert('消息', '撤回成功!', function(){
									var store = me.getStore();
									store.load();
								});
							}else{
								Ext.Msg.alert('消息', operation.error);
							}
						});
					}else{
						Ext.Ajax.request({
							url:store.noIssueUrl,
							params: {
	                  			searchPlanIds: planIds
							},
							success:function(response){
								var data=response.responseText;
								var json=Ext.decode(data,true);
								if(json.success){
									Orchid.alert('提示','撤回成功!',function(){
										store.load();
									});
								}else{
									Orchid.alert('提示',json.msg);
								}
							}
						});
					}
				}
			}
		});
	},
  //导入名额
    onImportquotasClick: function(){
		var me = this;
    	Ext.create("PJ.view.quotamanagement.BatchImportEdit", {
			title: "导入名额",
			height: 110,
			width: 380,
			grid: me
		}).show();
    },
    /**
     * 导入培训班信息
     */
    onImportCourseInformationClick: function(){
    	var me = this;
		var records=me.getSelectionModel().getSelection();
        if(records == null || records.length == 0){
        	Orchid.alert("提示","请至少选择一个培训班！");
        	return;
        }
        if(records.length>1){
        	Orchid.alert("提示","只允许选择一个培训班！");
        	return;
        }
    	var applyNum = records[0].get("applyNum");
    	Ext.create("PJ.view.trainingprogram.CourseInformation", {
			title: "导入培训班信息",
			height: 140,
			width: 380,
			applyNum:applyNum,
			grid: me
		}).show();
    },
    /**
     * 计划名额
     */
    onPlanplacesClick: function(){
		var me = this;
		var record = this.getSelectionModel().getSelection();
        if(this.getSelectionModel().getCount() > 1){
            Ext.Msg.show({
                title: '提示',
                msg: '操作时只可选中一条记录！',
                icon: Ext.Msg.WARNING,
                buttons: Ext.Msg.OK
            });
        	return;
        }else{
        	Ext.create('AM.default.DefaultWindowView', {
                title: record[0].get("specialName"),
                height:550,
                width: 450,
                grid: me,
                planId:record[0].get("planId"),
                items: [{
                    xtype: 'planPlacesList'
                }],
                listeners: {
                	close: function(){
                		me.getStore().load();
                	}
                }
            });
        }
	},
    //预览
    listeners: {
		selectionchange: function(selModel, selected){
            this.down('#' + this.oldId + "Delete").setDisabled(selected.length === 0);//删除
//            this.down('#' + this.oldId + "Planplaces").setDisabled(selected.length === 0);//计划名额
            this.down('#' + this.oldId + "Issue").setDisabled(selected.length  === 0);//提交审核
            this.down('#' + this.oldId + "Issueno").setDisabled(selected.length  ===  0);//撤回审核
            //this.down('#' + this.oldId + "Comparisons").setDisabled(selected.length === 0);//导出详情及名额
            //this.down('#' + this.oldId + "Trainingprogram").setDisabled(selected.length === 0);//导出培训计划
            //this.down('#' + this.oldId + "Summarycomments").setDisabled(selected.length === 0);//导出意见汇总表
		},
		viewready: function(){
			var me = this;
			//导出按钮集合
        	var exportMenu = Ext.create('Ext.menu.Menu', {
                items: [{
                    text: '培训计划',
	        		iconCls: 'classIco',
	        		itemId: this.oldId + 'Trainingprogram',
	        		disabled: false,
                    listeners: {
                        click: function(btn){
                        	var records = me.getSelectionModel().getSelection();
                        	if(records != null && records.length > 0){
                        		var planIdstr = "";
                                for(var i = 0;i<records.length;i++){
                                	if(i == records.length-1){
                                		planIdstr += "searchplanIdList=" + records[i].get("planId");
                                	}else{
                                		planIdstr += "searchplanIdList=" + records[i].get("planId") + "&";
                                	}
                                }
                                var atag = Ext.get("exportResume");
                                var exportUrl = me.store.exportTrainingUrl;
                                atag.set({
                                    "href": exportUrl + '?' + planIdstr
                                });
                                atag.dom.click();
                        	}else{
                        		var store = me.getStore();
                                var params=store.proxy.extraParams;
                                var href=store.exportTrainingUrl + "?";
                                for(var param in params){
                                	if(params[param] === undefined){
                                		href+="&"+param+"=";
                                	}else{
                                		href+="&"+param+"="+params[param];
                                	}
                                }
                                href = encodeURI(href);
                                var atag = Ext.get("exportResume");
                                atag.set({
                                    "href": href
                                });
                                atag.dom.click();
                        	}
                            
                    	}
                    }
                }, {
                    text: '详情及名额',
	        		iconCls: 'comparisonsIco',
	        		itemId: this.oldId + 'Comparisons',
	        		disabled: false,
                    listeners: {
                    	click: function(btn){
                    		var records = me.getSelectionModel().getSelection();
                    		if(records != null && records.length > 0){
                    			var planIdstr = "";
                                for(var i = 0;i<records.length;i++){
                                	if(i == records.length-1){
                                		planIdstr += "searchPlanIds=" + records[i].get("planId");
                                	}else{
                                		planIdstr += "searchPlanIds=" + records[i].get("planId") + "&";
                                	}
                                }
                                var atag = Ext.get("exportResume");
                                var exportUrl = me.store.contrastPlacesUrl;
                                atag.set({
                                    "href": exportUrl + '?' + planIdstr
                                });
                                atag.dom.click();
                    		}else{
                    			var store = me.getStore();
                                var params=store.proxy.extraParams;
                                var href=store.contrastPlacesUrl + "?";
                                for(var param in params){
                                	if(params[param] === undefined){
                                		href+="&"+param+"=";
                                	}else{
                                		href+="&"+param+"="+params[param];
                                	}
                                }
                                href = encodeURI(href);
                                var atag = Ext.get("exportResume");
                                atag.set({
                                    "href": href
                                });
                                atag.dom.click();
                    		}
                    	}
                    }
                }, {
                    text: '意见汇总表',
	        		iconCls: 'classDetailsIco',
	        		itemId: this.oldId + 'Summarycomments',
	        		disabled: false,
                    listeners: {
                    	click: function(btn){
                    		var records = me.getSelectionModel().getSelection();
                    		if(records != null && records.length > 0){
                    			var planIdstr = "";
                                for(var i = 0;i<records.length;i++){
                                	if(i == records.length-1){
                                		planIdstr += "searchPlanIds=" + records[i].get("planId");
                                	}else{
                                		planIdstr += "searchPlanIds=" + records[i].get("planId") + "&";
                                	}
                                }
                                var atag = Ext.get("exportResume");
                                var exportUrl = me.store.summaryCommentsUrl;
                                atag.set({
                                    "href": exportUrl + '?' + planIdstr
                                });
                                atag.dom.click();
                    		}else{
                    			var store = me.getStore();
                                var params=store.proxy.extraParams;
                                var href=store.summaryCommentsUrl + "?";
                                for(var param in params){
                                	if(params[param] === undefined){
                                		href+="&"+param+"=";
                                	}else{
                                		href+="&"+param+"="+params[param];
                                	}
                                }
                                href = encodeURI(href);
                                var atag = Ext.get("exportResume");
                                atag.set({
                                    "href": href
                                });
                                atag.dom.click();
                    		}
                    	}
                    }
                }]
            });
			this.addDocked([{
				dock: 'top',
				xtype: "searchform",
				columnCount: 3,
				fieldDefaults: {
					labelAlign: 'right',
					labelWidth: 100
				},
				items: [{
					xtype: "textfield",
					fieldLabel: '计划申请编号',
					name: "searchApplyNum",
					maxLength: "50",
					emptyText: "请输入计划申请编号"
				},{
					xtype: "textfield",
					fieldLabel: '培训班名称',
					name: "searchClassName",
					maxLength: "50",
					emptyText: "请输入培训班名称"
				},{
					xtype: "combo",
					fieldLabel: '审核状态',
					name: "searchAuditState",
					store: Ext.create("Ext.data.ArrayStore", {
						fields: ['value', 'text'],
						data: [[1, '审核通过'],[2,'建议修改'],[3,'待审核'],[4,'未上报'],[5,'审核否决']]
					}),
					valueField: 'value',
					displayField: 'text',
					editable: false,
					emptyText: "请选择"
				},{
					xtype: "combo",
					fieldLabel: '下发状态',
					name: "searchIssuedState",
					store: Ext.create("Ext.data.ArrayStore", {
						fields: ['value', 'text'],
						data: [[1, '已下发'],[2,'未下发'],[3,'已反馈']]
					}),
					valueField: 'value',
					displayField: 'text',
					editable: false,
					emptyText: "请选择"
				},{
					xtype: "combo",
					fieldLabel: '发布状态',
					name: "searchPublishState",
					store: Ext.create("Ext.data.ArrayStore", {
						fields: ['value', 'text'],
						data: [[1, '已发布'],[2,'未发布']]
					}),
					valueField: 'value',
					displayField: 'text',
					editable: false,
					emptyText: "请选择"
				}],
				grid: this
			},{
				xtype: 'toolbar',
				dock: 'top',
				displayInfo: true,
				items: [this.addButton, "-", this.updateButton, "-", {
					text: '删除',
					iconCls: 'deleteIco',
					itemId: this.oldId + "Delete",
					disabled: true,
					scope: this,
					handler: this.onDeleteClick
				},"-",{
					text: '提交审核',
					iconCls: 'publishIco',
					itemId: this.oldId + "Issue",
					disabled: true,
					scope: this,
					handler: this.onIssueClick
				}, "-", {
					text: '撤回审核',
					iconCls: 'publishCancelIco',
					itemId: this.oldId + "Issueno",
					disabled: true,
					scope: this,
					handler: this.onIssuenoClick
				}, "-",{
					text: '导入名额',
					iconCls: 'batchImportRegistrationIco',
					itemId: this.oldId + "Importquotas",
					disabled: false,
					scope: this,
					handler: this.onImportquotasClick
				}, "-",{
					text: '导入培训班信息',
					iconCls: 'batchImportRegistrationIco',
					itemId: this.oldId + "importCourseInformation",
					disabled: false,
					scope: this,
					handler: this.onImportCourseInformationClick
				}/*,"-", {
					text: '查看计划名额',
					iconCls: 'planplacesIco',
					itemId: this.oldId + "Planplaces",
					disabled: true,
					scope: this,
					handler: this.onPlanplacesClick
				}*/,"-",{
                    text: '导出',
                	xtype: 'button',
                    cls: 'floater',
                    textAlign: 'right',
                    arrowAlign: 'right',
                    itemId: this.oldId + 'Export',
                    enableToggle: true,
                    disabled: false,
                    iconAlign: 'left',
                    iconCls: 'deriveIco',
                    pressedCls: 'x-btn-focus',
                    menuActiveCls: 'x-btn-menu-active',
                    menu: exportMenu
				},"->", this.countSelectPanel]
			}]);
            // 触发权限过滤事件
            me.fireEvent("permission", this);
		}
    }
});
